﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once
#include "GnufList.h"
#include "GnufQtItem.h"
#include <QtWidgets/QWidget>
#include <QComboBox>
#include "GnufAppearanceSetting.h"
namespace gnuf {

    class QtList final : public QtItemWith<QComboBox, List, QWidget*>
    {
        Q_OBJECT
    public:
        QtList(List* pList, QWidget* parent = nullptr);
        virtual ~QtList();
        virtual void refresh(EWhatDirty) override;
        void onTableRowSelectionChanged(bool select);
    protected:
        // Inherits from QComboBox...
        virtual void wheelEvent(QWheelEvent *) override;
        virtual void mousePressEvent(QMouseEvent* e) override;
        virtual void focusInEvent(QFocusEvent* e) override;
        virtual void focusOutEvent(QFocusEvent* e) override;
        virtual void enterEvent(QEvent*) override;
        virtual void leaveEvent(QEvent*) override;
        virtual void paintEvent(QPaintEvent* e) override;

    private slots:
        void onCurrentIndexChanged(int);

    private:
        void refreshList();
        void refreshCurrentIndex();
        void adjustStyle(bool);

        bool m_isElided = false;
    };
}
